import wepy from 'wepy';

import cates from '@/ass/cates.js';
export default class Home extends wepy.mixin {
  data = {
    // 全部分类数据
    catesList: [],
    // 侧边栏默认选中项
    activeKey: 0,
    // 二级分类数据
    secondCate: [],
  };

  config = {};

  methods = {
    sidebaritemChange(e) {
      console.log(e.detail);
      this.secondCate = this.catesList[e.detail].children;
    },
  };
  async getCatesList() {
    const res = cates;
    // const { data: res } = await wepy.get('/categories');
    // console.log(res);
    if (res.meta.status !== 200) return wepy.baseToast();
    this.catesList = res.message;
    this.secondCate = this.catesList[0].children;
    console.log(this.catesList);
  }
  onLoad() {
    this.getCatesList();
  }
  onShow(){
    this.$parent.setTabBarBadge()
  }
}
